<template>
<h1>计算器练习</h1>
  <input type="text" v-model="num1" placeholder="请输入数字1" ><br>
  <input type="text" v-model="num2" placeholder="请输入数字2"><br>
  <button @click="ref('+')">加</button>
  <button @click="ref('-')">减</button>
  <button @click="ref('*')">乘</button>
  <button @click="ref('/')">除</button>
  <h4>结果为:{{result}}</h4>

</template>

<!-- eval-->
<script setup>
 import {ref} from "vue";

 const num1 = ref(0);
 const num2 = ref(0);
 const result =ref(0);

 const calc= (o)=>{
   result.value = eval(num1.value+o+num2.value);
 }

</script>

<style scoped>

</style>